package com.csd.action.teacher;

import javax.servlet.http.HttpSession;

import org.apache.struts2.ServletActionContext;

import com.csd.helper.ActionResult;
import com.csd.helper.IConstant;
import com.csd.helper.SessionManager;
import com.csd.serviceImpl.TeacherService;
import com.csd.vo.UserVO;
//import com.sun.mail.iap.Response;

/**
 * 
 * 教师个人信息修改Action类
 * @author 尹华彬
 * @version 1.0
 * 
 * <br> 修订时间：2009-12-17
 * <br> 修改原因：创建文件
 * <br> 修改人：尹华彬
 * 
 * <br> 
 * 
 */
public class TeacherUpdateAction {
	
	//老师电子邮件
	private String email;
	//老师电话
    private String phone;
    //老师个人站点
    private String website;
    //老师个人介绍
    private String introduction;
    //老师服务类
	private TeacherService teacherService;
	
	public TeacherService getTeacherService() {
		return teacherService;
	}
	public void setTeacherService(TeacherService teacherService) {
		this.teacherService = teacherService;
	}
    
	public String getEmail() {
		return email;
	}
	public void setEmail(String email) {
		this.email = email;
	}
	public String getPhone() {
		return phone;
	}
	public void setPhone(String phone) {
		this.phone = phone;
	}
	public String getWebsite() {
		return website;
	}
	public void setWebsite(String website) {
		this.website = website;
	}
	public String getIntroduction() {
		return introduction;
	}
	public void setIntroduction(String introduction) {
		this.introduction = introduction;
	}
	public String execute()
	{
		//通过教师ID 完成个人信息修改//通过教师ID 完成个人信息修改
		String result = ActionResult.fail;
		System.out.println("come on");
		Integer teacherID = null;
		//获得老师ID		
		try {
			HttpSession httpSession = ServletActionContext.getRequest().getSession();
			UserVO value = (UserVO)httpSession.getAttribute(IConstant.userVO);
			if(value == null){
				throw  new Exception("用户未登录异常");
			}
			teacherID = value.getUserID();
		} catch (Exception e) {
			e.printStackTrace();
			return result;
		}
		//更新老师个人信息
		teacherService.updateTeacherInfo(teacherID, email, phone, website, introduction);
		result = ActionResult.success;
		return result ;
	}

}
